import axios from "axios";
import config from "@/config";

class Http {
  async get(url: string, params: any = {}, header: any = {}): Promise<any> {
    this.SetBaseUrl();
    return await axios.get(url, {
      params: params,
      headers: header,
    });
  }

  async post(url: string, params: any = {}, header: any = {}): Promise<any> {
    this.SetBaseUrl();
    return await axios.post(url, params, {
      headers: header,
    });
  }

  SetBaseUrl() {
    if (axios.defaults.baseURL == null) {
      axios.defaults.baseURL = config.check();
    }
  }
}

export default new Http();
